{  ACMP.RU
   Problem 6. Text of problem: http://acmp.ru/?main=task&id_task=6
   Verdict: Accepted
}
uses 
  SysUtils, Math;

var
    a,b,c,d:longint;
    s:string;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(S);
if (length(s)=5) and (s[1] in ['A'..'H']) and (s[2] in ['1'..'8']) and (s[3]='-') and (s[4] in ['A'..'H']) and (s[5] in ['1'..'8']) then begin
    a:=ord(s[1])-64;
    b:=ord(s[2])-48;
    c:=ord(s[4])-64;
    d:=ord(s[5])-48;
    if ((abs(d-b)=2) and (abs(c-a)=1)) or ((abs(c-a)=2) and (abs(d-b)=1)) then write('YES') else write('NO');
end else write('ERROR');
end.